package com.hockeo.shared.rpc.classic;


/**
 * A special callback that forwards its result processing to a class that implements
 * {@link IRpcResultReceiver}.
 *
 * @version $Id$
 * @author jjanke
 */
public class RpcReceiverCallback<T> extends RpcCallback<T>
{
  private final IRpcResultReceiver<T> d_receiver;
  private final String               d_strPurpose;

  /**
   * Creates a new VHRpcCallback object.
   *
   * @param receiver the object to which the result of an RPC should be set.
   * @param strPurpose the purpose of the data that is returned to the result recipient
   *          (useful if a recipient receives data for multiple different purposes), may
   *          be <code>null</code> if the receiver only receives data for a single
   *          well-determined purpose
   */
  public RpcReceiverCallback( IRpcResultReceiver<T> receiver, String strPurpose )
  {
    d_receiver = receiver;
    d_strPurpose = strPurpose;
  }

  @Override
  public void processResult( T result )
  {
    d_receiver.processRpcResult( result, d_strPurpose );
  }
}
